// 页面搜索条件配置
export const searchColumns = (that) => [
  <#list searchColumns as col>
    <#if (col.type == 'input')>
    {
      prop: '${col.name}',
      label: '${col.description}',
      type: 'input',
      componentProp: {
        clearable: true,
        placeholder: '请输入${col.description}',
      },
      componentEvent: {},
    },
    <#elseif (col.type == 'dateRange')>
    {
      prop: '${col.name}',
      label: '${col.description}'
      type: 'date-range-picker',
      format: 'yyyy-MM-dd HH:mm:ss',
    },
    <#else>
    {
      prop: '${col.name}',
      label: '${col.description}',
      type: 'custom',
    },
    </#if>
  </#list>
];

// 页面表格配置
export const tableSchema = [
  {
    type: 'selection',
    fixed: 'left',
  },
  <#list tableColumns as col>
    <#if (col.type == 'normal')>
    {
      label: '${col.description}',
      dataIndex: '${col.name}',
      width: '180',
    },
    <#else>
    {
      label: '${col.description}',
      dataIndex: '${col.name}',
      customSlot: '${col.name}',
      width: '180',
    },
    </#if>
  </#list>
];

// 表格操作配置
export const tableActions = (handleUpdate, handleStatusChange, handleShowDetail) => [
  {
    width: 220,
    label: '操作',
    buttons: [
      {
        label: '查看详情',
        onClick: (row) => {
          handleShowDetail(row);
        },
      },
      {
        label: '编辑',
        onClick: (row) => {
          handleUpdate(row);
        },
      },
      {
        label: '禁用',
        onClick: (row) => {
          handleStatusChange(row);
        },
      }
    ],
  },
];
